home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / utility / 601 / changesz / ezmac.s < prev   
Encoding:
Text File  |  1992-03-07  |  11.6 KB  |  466 lines

  1. ; EZ MACROS   by Michael LaChapelle (MJL!)
  2. ; last update: 9/19/89
  3.   Text
  4.   CursConf #0,#5                    ;get initial flash rate...
  5.   Move d0,flashrate__               ;...and save it for CURSOR macro
  6.  
  7.   Data
  8. hextable__ dc.b '0123456789ABCDEF'  ;data for PRINTHEX
  9. crlf__ dc.b $0d,$0a,0,0
  10. up__ dc.b 'A',0,0
  11. down__ dc.b 'B',0,0
  12. right__ dc.b 'C',0,0
  13. left__ dc.b 'D',0,0
  14. cls__ dc.b 'E',0,0
  15. home__ dc.b 'H',0,0
  16. EEOS__ dc.b 'J',0,0
  17. EEOLn__ dc.b 'K',0,0
  18. Insert__ dc.b 'L',0,0
  19. Delete__ dc.b 'M',0,0
  20. CharColor__ dc.b 'b'
  21. CColor__ dc.b ' ',0
  22. BackColor__ dc.b 'c'
  23. BColor__ dc.b ' ',0
  24. ClrtoCrs__ dc.b 'd',0,0
  25. SaveCrs__ dc.b 'j',0,0
  26. RestoreCrs__ dc.b 'k',0,0
  27. ClearLine__ dc.b 'l',0,0
  28. ClrfromSt__ dc.b 'o',0,0
  29. ReverseOn__ dc.b 'p',0,0
  30. ReverseOff__ dc.b 'q',0,0
  31. WrapOn__ dc.b 'v',0,0
  32. WrapOff__ dc.b 'w',0,0
  33. position__ dc.b 'Y'
  34. positiony__ dc.b ' '
  35. positionx__ dc.b ' '
  36.             dc.b 0,0
  37.   BSS
  38. flashrate__ ds.w 1                  ;for CURSOR
  39. InputBuffer__ ds.b 82
  40. Registers:                          ;register save area (for BP)
  41. D0__  DS.W 1
  42. D02__ DS.W 1
  43. D1__  DS.W 1
  44. D12__ DS.W 1
  45. D2__  DS.W 1
  46. D22__ DS.W 1
  47. D3__  DS.W 1
  48. D32__ DS.W 1
  49. D4__  DS.W 1
  50. D42__ DS.W 1
  51. D5__  DS.W 1
  52. D52__ DS.W 1
  53. D6__  DS.W 1
  54. D62__ DS.W 1
  55. D7__  DS.W 1
  56. D72__ DS.W 1
  57. A0__  DS.W 1
  58. A02__ DS.W 1
  59. A1__  DS.W 1
  60. A12__ DS.W 1
  61. A2__  DS.W 1
  62. A22__ DS.W 1
  63. A3__  DS.W 1
  64. A32__ DS.W 1
  65. A4__  DS.W 1
  66. A42__ DS.W 1
  67. A5__  DS.W 1
  68. A52__ DS.W 1
  69. A6__  DS.W 1
  70. A62__ DS.W 1
  71. A7__  DS.W 1
  72. A72__ DS.W 1
  73. ST0__  DS.W 1
  74. ST02__ DS.W 1
  75. ST1__  DS.W 1
  76. ST12__ DS.W 1
  77. ST2__  DS.W 1
  78. ST22__ DS.W 1
  79. ST3__  DS.W 1
  80. ST32__ DS.W 1
  81.  
  82.   Text
  83.  
  84. off=0                               ;cursor equates
  85. on=1
  86. flash=2
  87. steady=3
  88. solid=3
  89.  
  90. for_read=0                          ;for OPEN #FOR_READ...
  91. for_write=1                         ;for OPEN #FOR_WRITE...
  92. for_rw=2                            ;for OPEN #FOR_RW...
  93.  
  94. Push: Macro $\1                     ;PUSH <register D0-D7, A0-A6>
  95.   Move.l \1,-(sp)                   ;(saves register on stack)
  96.   Endm
  97.  
  98. Pop: Macro $\1                      ;POP <register D0-D7, A0-A6>
  99.   Move.l (sp)+,\1                   ;(pulls value from stack)
  100.   Endm
  101.  
  102. Pull: Macro $\1                     ;PULL <register D0-D7, A0-A6>
  103.   Pop \1
  104.   Endm
  105.  
  106. CR: Macro                           ;CR
  107.   PrintLine crlf__                  ;(prints a CR, LF)
  108.   Endm
  109.  
  110. CapsIn: Macro                       ;CAPSIN
  111.   conin_we                          ;(converts letter to uppercase,)
  112.   and.b #$5F,d0                     ;(without echo)
  113.   Endm
  114.  
  115. KeyIn: Macro                        ;KEYIN
  116.   conin_we                          ;(get any key, without echo)
  117.   Endm
  118.  
  119. CheckKey: Macro                     ;CHECKKEY
  120.   RawConIO #$FF                     ;(returns key in D0, or '0' if no)
  121.   tst d0                            ;(key pressed)
  122.   endm
  123.  
  124. Up: Macro                           ;UP
  125.   PrintLine Up__                    ;(moves cursor up 1 line)
  126.   Endm                              ;(no scroll)
  127.  
  128. Down: Macro                         ;DOWN
  129.   PrintLine Down__                  ;(moves cursor down 1 line)
  130.   Endm                              ;(no scroll)
  131.  
  132. Right: Macro                        ;RIGHT
  133.   PrintLine Right__                 ;(moves cursor right 1 space)
  134.   Endm
  135.  
  136. Left: Macro                         ;LEFT
  137.   PrintLine Left__                  ;(moves cursor left 1 space)
  138.   Endm
  139.  
  140. Cls: Macro                          ;CLS
  141.   PrintLine Cls__                   ;(clears screen)
  142.   Endm
  143.  
  144. Home: Macro                         ;HOME
  145.   PrintLine Home__                  ;(homes cursor, no screen clear)
  146.   Endm
  147.  
  148. EraseEOS: Macro                     ;ERASEEOS
  149.   PrintLine EEOS__                  ;(erase to end of screen)
  150.   Endm
  151.  
  152. EraseEOLn: Macro                    ;ERASEEOLN
  153.   PrintLine EEOLn__                 ;(erase to end of line)
  154.   Endm
  155.  
  156. InsertLine: Macro                   ;INSERTLINE
  157.   PrintLine Insert__                ;(insert line)
  158.   Endm
  159.  
  160. DeleteLine: Macro                   ;DELETELINE
  161.   PrintLine Delete__                ;(delete line)
  162.   Endm
  163.  
  164. CharColor: Macro $\1                ;CHARCOLOR <color 0-15>
  165.   move.b \1,CColor__                ;(sets character color)
  166.   PrintLine CharColor__
  167.   Endm
  168.  
  169. BackColor: Macro $\1                ;BACKCOLOR <color 0-15>
  170.   move.b \1,BColor__                ;(sets character background color)
  171.   PrintLine BackColor__
  172.   Endm
  173.  
  174. ClearToCursor: Macro                ;CLEARTOCURSOR
  175.   PrintLine ClrtoCrs__              ;(clears from screen start to cursor)
  176.   Endm
  177.  
  178. SaveCursor: Macro                   ;SAVECURSOR
  179.   PrintLine SaveCrs__               ;(save cursor position)
  180.   Endm
  181.  
  182. RestoreCursor: Macro                ;RESTORECURSOR
  183.   PrintLine RestoreCrs__            ;(restore cursor to saved position)
  184.   Endm
  185.  
  186. ClearLine: Macro                    ;CLEARLINE
  187.   PrintLine ClearLine__             ;(erase entire line)
  188.   Endm
  189.  
  190. ClearFromStart: Macro               ;CLEARFROMSTART
  191.   PrintLine ClrFromSt__             ;(clear from line start to cursor)
  192.   Endm
  193.  
  194. ReverseOn: Macro                    ;REVERSEON
  195.   PrintLine ReverseOn__             ;(inverse letters)
  196.   Endm
  197.  
  198. ReverseOff: Macro                   ;REVERSEOFF
  199.   PrintLine ReverseOff__            ;(return to normal letters)
  200.   Endm
  201.  
  202. WrapOn: Macro                       ;WRAPON
  203.   PrintLine WrapOn__                ;(turn on word-wrap)
  204.   Endm
  205.  
  206. WrapOff: Macro                      ;WRAPOFF
  207.   PrintLine WrapOff__               ;(turn word-wrap off)
  208.   Endm
  209.  
  210. Position: Macro $\1,$\2             ;POSITION <x 0-39/79>,<y 0-24>
  211.   move \1,d0                        ;(positions cursor)
  212.   add #32,d0
  213.   move.b d0,positionx__
  214.   move \2,d0
  215.   add #32,d0
  216.   move.b d0,positiony__
  217.   PrintLine position__
  218.   Endm
  219.  
  220. VPrint: Macro $\1                   ;VPRINT <variable/label>
  221.   PrintLine \1                      ;(variable print)
  222.   Endm
  223.  
  224. VPrint_at: Macro $\1,$\2,$\3        ;VPRINT_AT <x>,<y>,<var/label>
  225.   Position \1,\2                    ;(displays var output at x,y)
  226.   VPrint \3
  227.   Endm
  228.  
  229. VPrintCR: Macro $\1                 ;VPRINTCR <var/label>
  230.   VPrint \1                         ;(print var/label, do CRLF)
  231.   CR
  232.   Endm
  233.  
  234. VPrintCR_At: Macro $\1,$\2,$\3      ;VPRINTCR_AT <x>,<y>,<var/label>
  235.   Position \1,\2                    ;(print var at x,y, do CRLF)
  236.   VPrintCR \3
  237.   Endm
  238.  
  239. Print: Macro $\1                    ;PRINT '<string>'
  240.   PrintLine \prt                    ;(print literal string)
  241.   bra.s \prtend
  242. \prt dc.b \1,0
  243.   align
  244. \prtend:
  245.   Endm
  246.  
  247. Print_at: Macro $\1,$\2,$\3         ;PRINT_AT <x>,<y>,'<string>'
  248.   Position \1,\2                    ;(print string at x,y)
  249.   Print \3
  250.   Endm
  251.  
  252. PrintCR: Macro $\1                  ;PRINTCR '<string>'
  253.   Print \1                          ;(print literal string, do CRLF)
  254.   CR
  255.   Endm
  256.  
  257. PrintCR_At: Macro $\1,$\2,$\3       ;PRINTCR_AT <x>,<y>,'<string>'
  258.   Position \1,\2                    ;(print string at x,y, do CRLF)
  259.   PrintLine \prtcr
  260.   bra.s \prtcrend
  261. \prtcr dc.b \3
  262.   dc.b $0d,$0a,0
  263.   align
  264. \prtcrend:
  265.   Endm
  266.  
  267. Input: Macro $\1,$\2                ;INPUT <var/label>,<max length>
  268.   move.b \2,INPUTBUFFER__             ;(places input in var, actual)
  269.   ReadLine INPUTBUFFER__              ;(length in D0)
  270.   Push d0                             ;(also places zero byte at end)
  271.   CR                                  ;(of input text)
  272.   Pop d0
  273.   lea \1,a0
  274.   lea INPUTBUFFER__+2,a1
  275.   move d0,d1
  276.   subq #1,d1
  277. \InLoop: move.b (a1)+,(a0)+
  278.   dbra d1,\InLoop
  279.   move.b #0,(a0)+
  280.   Endm
  281.  
  282. Input_at: Macro $\1,$\2,$\3,$\4     ;INPUT_AT <x>,<y>,<var/label>,<len>
  283.   Position \1,\2                    ;(positions cursor to x,y,)
  284.   Input \3,\4                       ;(does INPUT)
  285.   Endm
  286.  
  287. Cursor: Macro %\1                   ;CURSOR ON     (turns cursor on)
  288.   Ifeq \1,Off                       ;CURSOR OFF    (turns cursor off)
  289.     CursConf #0,#Off                ;CURSOR STEADY (no flash)
  290.   Endif                             ;CURSOR SOLID  (    "   )
  291.   Ifeq \1,On                        ;CURSOR FLASH  (flash cursor)
  292.     CursConf #0,#On
  293.   Endif
  294.   Ifeq \1,Steady
  295.     CursConf #0,#Steady
  296.   Endif
  297.   Ifeq \1,Solid
  298.     CursConf #0,#Solid
  299.   Endif
  300.   Ifeq \1,Flash
  301.     CursConf FlashRate__,#Flash
  302.   Endif
  303.   Endm
  304.  
  305. PrintHex: Macro $\1                 ;PRINTHEX <#/var/label>
  306.   move.b \1,d0                      ;(displays hexidecimal value)
  307.   ext.w d0
  308.   move d0,a1
  309.   lsr.b #4,d0
  310.   andi #$0f,d0
  311.   lea hextable__,a2
  312.   move.b (a2,d0),d2
  313.   lsl #8,d2
  314.   move a1,d0
  315.   andi #$0f,d0
  316.   move.b (a2,d0),d2
  317.   move d2,d0
  318.   Push d2
  319.   lsr #8,d0
  320.   ConOut d0
  321.   pop d0
  322.   ConOut d0
  323.   Endm
  324.  
  325. PrintHexCR: Macro $\1               ;PRINTHEXCR <#/var/label>
  326.   PrintHex \1                       ;(print hex value, do CRLF)
  327.   CR
  328.   Endm
  329.  
  330. PrintHex_At: Macro $\1,$\2,$\3      ;PRINTHEX_AT <x>,<y>,<#/var/label>
  331.   Position \1,\2                    ;(print hex at x,y)
  332.   PrintHex \3
  333.   Endm
  334.  
  335. PrintHexCR_At: Macro $\1,$\2,$\3    ;PRINTHEXCR_AT <x>,<y>,<#/var/label>
  336.   PrintHex_At \1,\2,\3              ;(print hex at x,y, do CRLF)
  337.   CR
  338.   Endm
  339.  
  340. Dump: Macro $\1                     ;DUMP <#/var/label>
  341.   PrintHex \1                       ;(display hex word value)
  342.   PrintHex \1+1
  343.   Endm
  344.  
  345. DumpHex: Macro $\1                  ;DUMPHEX <#/var/label>
  346.   Dump \1                           ;(16-bit hex dump)
  347.   Endm
  348.  
  349. DumpCR: Macro $\1                   ;DUMPCR <#/var/label>
  350.   PrintHex \1                       ;(display hex, do CRLF)
  351.   PrintHexCR \1+1
  352.   Endm
  353.  
  354. DumpHexCR: Macro $\1                ;DUMPHEXCR <#/var/label>
  355.   DumpCR \1                         ;(16-bit hex dump, do CRLF)
  356.   Endm
  357.  
  358. Dump_At: Macro $\1,$\2,$\3          ;DUMP_AT <x>,<y>,<#/var/label>
  359.   PrintHex_At \1,\2                 ;(display hex at x/y)
  360.   PrintHex \3
  361.   Endm
  362.  
  363. DumpHex_At: Macro $\1,$\2,$\3       ;DUMPHEX_AT <x>,<y>,<#/var/label>
  364.   Dump_At \1,\2,\3                  ;(16-bit dump at x/y)
  365.   Endm
  366.  
  367. DumpCR_At: Macro $\1,$\2,$\3        ;DUMPCR_AT <x>,<y>,<#/var/label>
  368.   PrintHex_At \1,\2                 ;(display hex at x/y, do CRLF)
  369.   PrintHexCR \3
  370.   Endm
  371.  
  372. DumpHexCR_At: Macro $\1,$\2,$\3     ;DUMPHEXCR_AT <x>,<y>,<#/var/label>
  373.   DumpCR_At \1,\2,\3                ;(16-bit dump at x/y, do CRLF)
  374.   Endm
  375.  
  376. BP: Macro $\1                       ;BP <text>
  377.   Print \1                          ;(halt and display msg [BreakPoint])
  378.   KeyIn
  379.   ClearLine
  380.   Endm
  381.  
  382. BreakPoint: Macro $\1               ;BREAKPOINT <text>
  383.   BP \1
  384.   Endm
  385.  
  386. BPDump: Macro $\1                   ;BPDUMP <text>
  387.   MoveM.L D0-D7/A0-A6,Registers     ;(BreakPoint and DUMP registers)
  388.   Move.L SP,A7__
  389.   Move.L (SP),ST0__
  390.   Move.L +4(SP),ST1__
  391.   Move.L +8(SP),ST2__
  392.   Move.L +12(SP),ST3__
  393.   PrintCR \1
  394.   CR
  395.   Print ' --A0--   --A1--   --A2--   --A3-- '
  396.   PrintCR '  --A4--   --A5--   --A6--   --SP-- '
  397.   Dump A0__
  398.   Dump A02__
  399.   Print ' '
  400.   Dump A1__
  401.   Dump A12__
  402.   Print ' '
  403.   Dump A2__
  404.   Dump A22__
  405.   Print ' '
  406.   Dump A3__
  407.   Dump A32__
  408.   Print ' '
  409.   Dump A4__
  410.   Dump A42__
  411.   Print ' '
  412.   Dump A5__
  413.   Dump A52__
  414.   Print ' '
  415.   Dump A6__
  416.   Dump A62__
  417.   Print ' '
  418.   Dump A7__
  419.   DumpCR A72__
  420.   CR
  421.   Print ' --D0--   --D1--   --D2--   --D3-- '
  422.   PrintCR '  --D4--   --D5--   --D6--   --D7-- '
  423.   Dump D0__
  424.   Dump D02__
  425.   Print ' '
  426.   Dump D1__
  427.   Dump D12__
  428.   Print ' '
  429.   Dump D2__
  430.   Dump D22__
  431.   Print ' '
  432.   Dump D3__
  433.   Dump D32__
  434.   Print ' '
  435.   Dump D4__
  436.   Dump D42__
  437.   Print ' '
  438.   Dump D5__
  439.   Dump D52__
  440.   Print ' '
  441.   Dump D6__
  442.   Dump D62__
  443.   Print ' '
  444.   Dump D7__
  445.   DumpCR D72__
  446.   CR
  447.   PrintCR ' Stack0   Stack1   Stack2   Stack3 '
  448.   Dump ST0__
  449.   Dump ST02__
  450.   Print ' '
  451.   Dump ST1__
  452.   Dump ST12__
  453.   Print ' '
  454.   Dump ST2__
  455.   Dump ST22__
  456.   Print ' '
  457.   Dump ST3__
  458.   DumpCR ST32__
  459.   MoveM.L Registers,D0-D7/A0-A6
  460.   KeyIn
  461.   CR
  462.   EndM
  463.  
  464.   End
  465.